package com.example.leetcode;

/**
 * 最大重复子字符串
 */
public class MaxRepeatedNum {

    public static int maxRepeating(String sequence, String word) {
        int k = 0;
        StringBuilder sb = new StringBuilder(word);
        while (sequence.contains(word)) {
            k++;
            sb.append(word);
            // 当遍历的数据已经完全超过比对词，那么就跳出
            if (sb.length() > sequence.length()) break;
        }
        return k;
    }

    public static void main(String[] args) {
        System.out.println(maxRepeating("ababa", "ab"));
    }
}
